package com.dragon.repository.mapper;

import com.dragon.repository.entity.ProcurementProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 采购物品表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-10-25
 */
@Mapper
public interface ProcurementProductMapper extends BaseMapper<ProcurementProduct> {

    @Select("SELECT N.* FROM (select a.*, aa.spu_specification as specificationName, aa.name as productName, au.name as unitName  from dragon_procurement_product a " +
            "left join dragon_product aa on a.product_spu_id = aa.id " +
            "left join dragon_product_unit au on a.unit_id = au.id )N WHERE 1=1 and N.procurement_id = #{id} " )
    List<ProcurementProduct> selectListByProcurementId(Integer id);
}
